<style> /* input,.btn{margin-top: 20px;} */.notice{color: red;border: 0;padding-left:5px;height: 20px;line-height:20px;display: none;font-size: 16px;text-align: left;} .code{width: 110px;height: 38px;border: 0px solid black;position:absolute;right:0;  margin-top:4px;margin-right: 10px;} a{color: black;} .content-middle-body > input, .content-middle-body > button, .content-middle-body > a { margin-top:6px; margin-bottom: 6px; } #tryplay { display:none; } #tryplay.active { display: inline-block; } </style>
<div class="wapper" id="zhuce">
<div class="bg-theme text-center top col-xs-12 col-sm-4 col-sm-offset-4">
			<span>用户注册</span>
			<a class="glyphicon glyphicon-chevron-left fl" onclick="backPage()" style="color: white;position:absolute;top: 50%;transform:translateY(-50%);left:10px;"></a>
		</div>
		<div class="text-center content-middle-body col-xs-12 col-sm-4 col-sm-offset-4" style="margin-top:40px;">
			<!-- 正文开始 -->
			<input id="name" type="text" placeholder="用户名(4-10位)" maxlength="10" class="form-control input-lg" style="margin-top:25px;"></input>
			<input id="pass1" type="password" placeholder="密码(6-16位字母、数字)" maxlength="16" class="form-control input-lg" ></input>
			<input id="pass2" type="password" placeholder="再次输入密码" maxlength="16" class="form-control input-lg" ></input>
			<input id="qq" type="text" placeholder="QQ号码[重要!只能输入数字]" maxlength="16" oninput="value=value.replace(/[^\d]/g,'')"  class="form-control input-lg" ></input>
			<input id="telephone" type="text" placeholder="手机号码[重要 !只能输入数字]" maxlength="11" oninput="value=value.replace(/[^\d]/g,'')" class="form-control input-lg" ></input>
			<input id="invitationCode" type="text" placeholder="邀请码[重要 !只能输入数字]" maxlength="11"  class="form-control input-lg" ></input>
			<div style="position: relative;">
				<img src="/u/code.do" class="code" />
				<input id="code" type="text" placeholder="验证码!只能输入数字" maxlength="4" oninput="value=value.replace(/[^\d]/g,'')" class="form-control input-lg" ></input>
				
			</div>
			
			<input type="checkbox" class="bg-danger" checked="checked" /> 我已阅读《<a href="" class="text-danger">用户购彩服务协议</a>》
			<button id="register" class="btn btn-lg disabled pm bg-theme">立即注册</button>
			<a  class="GoToPage login btn btn-lg pm bg-theme ">立即登录</a>
			<button id="tryplay" class="GoToPage tryplay btn btn-lg pm bg-theme">免费试玩</button>
			<!-- 正文结束 -->
		</div>
<div class="modal-div-fakeModal" id="div-i-noticeGenDan">
	<div class="div-c-modalContent">
		<h3 class="fakemodal-title"></h3>
		<div class="fakemodal-content"></div>
		<div class="fakemodal-btnsGroup"><button class="btn btn-default btn-class-closeFakeModal">关闭</button></div>
	</div>
</div>	
</div>	

<script>
	setContentBodyHeight();
	fixHeadAndFoot();
	
		$(function(){
			var nameOk=false;
			var html="<span class='notice'></span>";
			var phone=/^[1][3,4,5,7,8,9][0-9]{9}$/;
			var qqReg = /^[1-9]\d{6,10}$/;
			var pattname = /^[A-z\d]{4,10}$/;
				/* 检验填写信息是否正确 */
		        $("input").focus(function(){
		        	if($(this).next().hasClass("notice")){
			        	 
			        }else{
			        	 $(this).after(html);
			        }
		        }).blur(function(){
		        	if($(this).val().trim()!=""){
		        		if(isNull(this)!=true){
			        		$(this).next().css("display","block");
							$(this).next().text(isNull(this));
						}else{
							$(this).next().remove();	
						}
		        	}else{
		        		$(this).next().remove();
		        	}
		        });
		        
		        function isNull(that){
					if($(that).attr('id')=='name'){
						if(!pattname.test($(that).val())) return "账号为4到10位的数字或字母";
						else return true;
					}else if($(that).attr('id')=='pass1'){
						if($(that).val().length<6||$(that).val().length>16) return "密码不能小于6位或大于16位";
						else return true;
					}else if($(that).attr('id')=='pass2'){
					if($("#pass1").val()!=$("#pass2").val() && ($(that).val().length<6||$(that).val().length>16)) return "两次密码输入不一致";
						else return true;
					}else if($(that).attr('id')=='qq'){
						 if(!qqReg.test($(that).val())) return "请输入正确的QQ号";
						else return true;
					}else if($(that).attr('id')=='telephone'){
						if(!phone.test($(that).val())) return "请输入正确的手机号";
						else return true;
					}else if($(that).attr('id')=='code'){
						if($(that).val().length!=4) return "请输入正确的验证码";
						else return true;
					}else if($(that).attr('id')=='invitationCode'){
						if($(that).val().length >= 3){
							return true;
						}
					}
				} 
		        
		        
		        
		        
			$(".content-middle-body").on("click","#register",function(){
				if (!$("#name").val() || !$("#pass1").val() || !$("#pass2").val() || !$("#qq").val() || !$("#telephone").val() || !$("#code").val()) {
					showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "请填写完整信息");
					bindAllCloseFakeModalBtns();
					return;
				}
				if($('.notice').length>0){
					showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "请填写正确信息");
					bindAllCloseFakeModalBtns();
					return;
				}
					$.ajax({
						url:'/u/register.do',
						data:{name:$("#name").val(),pass:$("#pass1").val(),qq:$("#qq").val(),code:$("#code").val(), telephone: $("#telephone").val(),invitationCode: $("#invitationCode").val()},
						type:'post',
						success:function(data){
							if(data == 50) { 
								save.push("sy");
								bindSetData("login");
								return;
				   			}else if(data==60){
				   				pagePreserve();
				   				return;
				   			}
							if(data.message == 1){
								statu=1;
								showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "注册成功，页面将立即自动登录");
								save.pop();
								setTimeout(function() {
									bindSetData("sy");
									reconnect();
								}, 1000);
							}else if(data.message == 2){
								showNormalNoticeModal("#div-i-noticeGenDan", "提示：",'验证码输入错误请重新输入');
							}else if(data.message == 0){
								showNormalNoticeModal("#div-i-noticeGenDan", "提示：",'请重新刷新验证码');
							}else if(data.message == 3){
								showNormalNoticeModal("#div-i-noticeGenDan", "提示：",'注册次数过多请明日注册');
							}else if(data.message == 4){
								showNormalNoticeModal("#div-i-noticeGenDan", "提示：",'用户名已存在请更换用户名');
							}else if(data.message == 5){
								showNormalNoticeModal("#div-i-noticeGenDan", "提示：",data.data);
							}
							bindAllCloseFakeModalBtns();
						},
					});
			});
			$(".code").click(function(){
				$(".code").attr("src","/u/code.do?"+Math.random());
			});
		});
		
		$(".btn-class-closeFakeModal").on("click",function(){
				$("#div-i-noticeGenDan").attr("data-lock","false");
				$("#div-i-noticeGenDan").hide();
		});
		
	</script>
